import instance from './index';
import qs from 'qs';

const preUrlPath = '';
//获取权限列表
const request = {
  p: ['api:permission:fetch'],
  r: params => {
    return instance.get(`/permission/fetchPermissionList`, {params})
  }
};
//添加权限
const add = {
  p: ['api:role:addPermissionRlt'],
  r: params => {
    return instance.post(`/role/addPermissionRlt`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取权限信息
const info = {
  p: ['api:permission:fetch'],
  r: params => {
    return instance.get(`/role/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};

//关联角色--权限关联
const releroleAuth = {
  p: ['api:permission:addRoleRlt']
};
//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(`${preUrlPath}/GET/roles/notAllowed`, {params})
  }
}

export {
  request,
  remove,
  notAllowed,
  add,
  modify,
  info,
  releroleAuth
}
